package com.lulin.mall.search.controller;

import com.lulin.mall.search.service.MallSearchService;
import com.lulin.mall.search.vo.SearchParam;
import com.lulin.mall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


/**
 * @author lulin
 * @date 2022/11/23 14:25
 */
@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    /**
     * 跳转到商城系统页面
     */
    @GetMapping(value = {"/list.html", "/", "index.html"})
    public String listPage(SearchParam param, Model model) {
        //通过对应的service，根据传递过来的相关信息，去es中检索对应数据
        SearchResult search = mallSearchService.search(param);
        //添加到域
        model.addAttribute("result", search);
        //跳到index页面
        return "index";
    }

}
